const Sequelize = require('sequelize')

const { DB,
    DB_NAME,
    DB_PASSWORD,
    DB_HOST,
    DB_DIALECT,
    DB_POOL_MAX,
    DB_POOL_MIN,
    DB_ACQUIRE,
    DB_IDLE } = require('../config/config_dev')

const seq = new Sequelize(DB, DB_NAME, DB_PASSWORD, {
    host: DB_HOST,
    dialect: DB_DIALECT,
    pool: {
        max: Number(DB_POOL_MAX),
        min: Number(DB_POOL_MIN),
        acquire: DB_ACQUIRE,
        idle: DB_IDLE
    }
})


try {
    seq.authenticate().then(() => {
        console.log("数据库连接成功！")
    })
} catch (error) {
    console.error("数据库连接失败！=====>", error)
}


module.exports = seq